package com.itboye.textileexpes.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpes.beans.ForresterBeans;
import com.itboye.textileexpes.beans.RootBean;
import com.itboye.textileexpes.interfaces.IAppUpdate;
import com.itboye.textileexpes.interfaces.ICategory;
import com.itboye.textileexpes.interfaces.IGetYanZhengMa;
import com.itboye.textileexpes.interfaces.IMainCategory;
import com.itboye.textileexpes.repository.APPUpdateRepository;
import com.itboye.textileexpes.repository.CategoryRepository;
import com.itboye.textileexpes.repository.MainCategoryRepository;
import com.itboye.textileexpres.base.BasePresenter;
import com.itboye.textileexpres.base.ResultEntity;

public class MainCategoryPresenter extends BasePresenter implements
		IMainCategory<ForresterBeans> {
	// 查询一级类目
	public static final String category_success = MainPresenter.class.getName()
			+ "_category_success";
	public static final String category_fail = MainPresenter.class.getName()
			+ "_category_fail";

	public static final String Category2_success = MainPresenter.class
			.getName() + "_category2_success";
	public static final String Category2_fail = MainPresenter.class.getName()
			+ "_category2_fail";
	// 收藏类目
	public static final String collection_success = MainPresenter.class
			.getName() + "_collection_success";
	public static final String collection_fail = MainPresenter.class.getName()
			+ "_collection_fail";

	public MainCategoryPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ForresterBeans model) {
		// TODO Auto-generated method stub
		IMainCategory<ForresterBeans> cate = new MainCategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collection_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(collection_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		cate.getInfo(model);
	}

	@Override
	public void delete(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ForresterBeans model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ForresterBeans model) {
		// TODO Auto-generated method stub
		IMainCategory<ForresterBeans> cate = new MainCategoryRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(category_success);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(category_fail);
						setChanged();
						notifyObservers(result);

					}
				});
		cate.getInfo(model);
	}

	@Override
	public List<ForresterBeans> query(ForresterBeans model) {
		// TODO Auto-generated method stub
		return null;
	}

}
